package org.smile.homework03.arthas.custom;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class Goods {

    private List<GoodsItem> goodsItemList = new ArrayList<>();

    public ZHLIterator getZIterator() {
        return new ZIterator();
    }

    public void add(GoodsItem goodsItem) {
        this.goodsItemList.add(goodsItem);
    }

    class ZIterator implements ZHLIterator {
        int amount = 0;

        @Override
        public GoodsItem next() {
            GoodsItem goodsItem = goodsItemList.get(amount);
            amount++;
            return goodsItem;
        }

        @Override
        public boolean hasNext() {
            if (amount >= goodsItemList.size())
                return false;
            else return true;
        }
    }

}
